home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / pascal / em3270.zip / EM3270.DOC next >
Text File  |  1986-07-13  |  41KB  |  990 lines

  1.         Pascal Library Member EM3270.INC                 Page 1
  2.  
  3.  
  4.                                   INTRODUCTION                                  ____________
  5.  
  6.         The  EM3270  procedures are the copyrighted property of  Piedmont 
  7.         Specialty Software.  They are distributed as "Shareware" to  save 
  8.         the enormous costs of publishing,  advertising,  and distributing 
  9.         software through the normal commercial channels.  In keeping with 
  10.         the established "rules" of this type of distribution, we ask that 
  11.         you:
  12.  
  13.           1. Send $20.00 to Piedmont Specialty Software,  P. O. Box 6637, 
  14.              Macon, GA  31208, if you find the procedures useful.
  15.  
  16.           2. Use  the procedures for your personal use only.  If you wish 
  17.              to use them in software for commercial distribution,  please 
  18.              contact us at the above address or by telephone at (912) 474 
  19.              2318 for details of a commercial license.
  20.  
  21.           3. Distribute the procedures freely, so long as you
  22.  
  23.                   - do not modify them,
  24.                   - include this documentation with them,
  25.                   - include the acompanying demonstration program.
  26.  
  27.         We  have used these procedures in many programs in the  last  two 
  28.         years  and  have found their screen management facilities  to  be 
  29.         well  received by all users from novice to expert.  We hope  that 
  30.         you will find them as useful and productive as we have.
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.         Pascal Library Member EM3270.INC                 Page 2
  68.  
  69.  
  70.         I. PURPOSE
  71.  
  72.              Turbo  Pascal  library member EM3270.INC is an INCLUDE  file 
  73.              containing  a  set of procedures  which  allows  full-screen 
  74.              editing  patterned  after the IBM 3270 family of  terminals. 
  75.              The  3270  family consists of a number  of  terminal  models 
  76.              designed  to  connect to the System/370 family of  mainframe 
  77.              processors.  There are hundreds of thousands of them in  use 
  78.              by office workers all over the world.  They operate as "full 
  79.              screen  I/O"  terminals.  That is,  the mainframe  sends  an 
  80.              entire screen at a time to the terminal, the user enters and 
  81.              edits  all data on the screen while "disconnected" from  the 
  82.              mainframe,  and  when finished transmits the entire modified 
  83.              screen back to the mainframe by pressing one of the  "atten-
  84.              tion identifier" (AID) keys.
  85.  
  86.              The  EM3270 procedures facilitate writing programs in  Turbo 
  87.              Pascal which give the user the impression that he is working 
  88.              with  a 3270 terminal.  Then programming methods you use  in 
  89.              handling the screens are very different from those used by a 
  90.              mainframe programmer, but the appearance to the user closely 
  91.              mimics  a  3270 with only a few compromises made to  account 
  92.              for the differences in a PC keyboard and a 3270 keyboard.
  93.              
  94.              Significant features of the routines include:
  95.  
  96.                a. Attribute_bytes specifying visible or invisible, bright                   _______________                                         
  97.                   or dim,  steady or blinking characters,  foreground co-
  98.                   lors, and Modified Data Tags.
  99.                b. Cursor_control consisting of character right, character                   ______________                                          
  100.                   left,  tab forward, tab backward, home cursor, and next 
  101.                   line.
  102.                c. Field_selection  on  writes and reads to and  from  the                   _______________                                         
  103.                   screen.
  104.                d. Cursor_positioning  under program control  before  data                   __________________                                      
  105.                   entry.
  106.  
  107.         II. USAGE
  108.  
  109.           A. Program_Requirements             ____________________
  110.  
  111.              Before  inclusion of EM3270.INC,  the  following  statements 
  112.              must appear:
  113.  
  114.                   {$V-}
  115.                   . . .
  116.                   Const
  117.                     MaxFields = xxx;
  118.            
  119.              Where  xxx  is the maximum number of data fields  which  can                                                   ____                    
  120.              appear  on any screen,  and is from 1 to 255.  Any number of 
  121.              prompt fields can appear.             ______                   
  122.  
  123.              NOTE:  DO_NOT  SET  COMPILER DIRECTIVE {$U+} IN ANY  PROGRAM              NOTE:  DO_NOT  SET  COMPILER DIRECTIVE {$U+} IN ANY  PROGRAM              ______                    ______                                                
  124.              USING  THE EM3270 PROCEDURES.  TURBO DOES STRANGE THINGS  TO              USING  THE EM3270 PROCEDURES.  TURBO DOES STRANGE THINGS  TO 
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.         Pascal Library Member EM3270.INC                 Page 3                                                               
  134.  
  135.  
  136.              THE KEYBOARD BUFFER WITH THIS OPTION AND THE KEYBOARD  INPUT              THE KEYBOARD BUFFER WITH THIS OPTION AND THE KEYBOARD  INPUT 
  137.              PROCEDURES OF EM3270 BECOME FRIED.             PROCEDURES OF EM3270 BECOME FRIED.
  138.  
  139.              The EM3270 routines use the heap,  but should not  interfere 
  140.              with any other heap operations of the calling program.
  141.              THE  DISPOSE COMMAND IS USED IN HEAP MANAGEMENT.  A  CALLING                   _______                                                 
  142.              PROGRAM MUST NOT USE TURBO'S MARK AND RELEASE!!!!!                          ___                                  
  143.  
  144.           B. Initialization             ______________
  145.  
  146.              Before  any other EM3270 procedure is executed,  the  EM3270                      ___                                                  
  147.              system must be initialized by issuing the following command:                    ____                                                 
  148.  
  149.                   InitScreen;
  150.  
  151.              This command must be issued once and only once for an execu-
  152.              tion of your program.
  153.  
  154.           C. Screen_Handling_Logic             _____________________
  155.  
  156.              The  general flow of logic in handling a screen consists  of 
  157.              the following sequence:
  158.  
  159.                     .
  160.                     .
  161.                     .
  162.              Procedure PresentScreen1;
  163.                Const
  164.                 Strng1 : String[8] = "Prompt 1";
  165.                 Strng2 : String[8] = "Prompt 2";
  166.                     .
  167.                     .
  168.                     .
  169.              Begin 
  170.                NewScreen;          { clear all existing fields }
  171.                WritePrompt(1,1,Dim,8,Strng1); { write a prompt }
  172.                WritePrompt(2,1,Dim,8,Strng2); { write a prompt }
  173.                     .
  174.                     .              { repeat for all prompts }
  175.                     .
  176.                Attr := 0;      {Bright, Steady, Visible, Unchanged}
  177.                WriteField(10,1,Attr,14,' ')      { define field 1 }
  178.                WriteField(10,2,Attr,16,' ')      { define field 2 }
  179.                     .
  180.                     .              { repeat for all data fields }
  181.                     .
  182.              End;  { of procedure }
  183.                     .
  184.                     .
  185.                     .
  186.              Procedure GetScreen1;
  187.              Begin
  188.                ReadScreen(FieldNo,FK);   { open screen for input }
  189.                GetField(1,Varbl1,Attr);  { retrieve a data field}
  190.                GetField(2,Varbl2,Attr);  { retrieve a data field}
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.         Pascal Library Member EM3270.INC                 Page 4
  200.  
  201.  
  202.                     .
  203.                     .
  204.              End; { of procedure }
  205.                     .
  206.                     .
  207.              Procedure RewriteScreen1;
  208.              Begin
  209.                Attr := 0;
  210.                RewriteField(1,Varbl1,Attr); { rewrite field 1 bright }
  211.                RewriteField(2,Varbl2,Attr); { rewrite field 2 bright }
  212.                     .
  213.                     .
  214.                     .
  215.              End; { of procedure }
  216.                     .
  217.                     .
  218.              Begin     { begin mainline program }
  219.                InitScreen;  { Initialize EM3270 }
  220.                     .
  221.                     .       { open files, etc. }
  222.                     .
  223.                PresentScreen1;  { write blank screen 1 }
  224.                Repeat
  225.                  GetScreen1;
  226.                     .
  227.                     .            { process screen 1 variables }
  228.                     .
  229.                  RewriteScreen1; { replace fields with new values }
  230.                Until Finished;
  231.                     .
  232.                     .
  233.  
  234.              Each of the EM3270 procedures is covered in Section III.
  235.  
  236.           D. Data_Fields             ___________
  237.  
  238.              A  data field is a string which is written to the screen and                                 ______                                    
  239.              into  which  the  cursor can be moved  during  a  ReadScreen 
  240.              procedure.
  241.            
  242.              Every  data field written to the screen is assigned a  field 
  243.              number from 1 to MaxFields.  Data fields are numbered in the 
  244.              order in which you write them to the screen. It is up to you 
  245.              to keep track of what each field number contains. You always                                                                    ______ 
  246.              address a data field by its number.
  247.  
  248.              Care must be exercised in planning the sequence in which you 
  249.              write  data fields because cursor tabbing at program  execu-
  250.              tion  time is determined by field number.  (This is a depar-
  251.              ture from the 3270 standard,  in which the field sequence is 
  252.              always  left-to-right,  top-to-bottom.) If the cursor is  in 
  253.              field 14 and the tab key pressed,  it will jump to field 15, 
  254.              no matter where 15 is.  To keep from driving the user  nuts, 
  255.              screens  should  normally  be designed so  that  fields  are 
  256.              always  written  in the  3270  left-to-right,  top-to-bottom 
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.         Pascal Library Member EM3270.INC                 Page 5
  266.  
  267.  
  268.              sequence.
  269.  
  270.              An  example  of when you might want to place fields  out  of 
  271.              sequence  might  be a field that is almost always  the  same 
  272.              value,  but should visually appear close to some other vari-
  273.              able  on  the  screen (state abbreviation in  a  local  area 
  274.              mailing list,  for example).  In such a case, you can define 
  275.              it  as the last screen field and provide the default  value. 
  276.              The cursor will skip over the field in normal  tabbing,  but 
  277.              the  user can still reach it when it needs to be changed  by 
  278.              tabbing until the cursor finally does reach it.
  279.  
  280.              You  specify  the  position  and  length  of  a  data  field      
  281.              when  you  first  write it with  the  WriteField  procedure. 
  282.              Position  and  length are fixed at that time and  cannot  be 
  283.              changed afterward.  When you retrieve a data field (with the 
  284.              GetField  procedure),  the string returned is always of  the 
  285.              length specified when the field was first written.
  286.  
  287.              You  also  specify  the attribute of a data field  when  you 
  288.              write it. (Attributes are discussed fully below.) The attri-
  289.              bute  of  a data field can be changed when you  rewrite  the                                     ___                                   
  290.              field,  and  its  Modified  Data Tag  bit  is  automatically 
  291.              changed  if  any  data  in the field  is  changed  during  a 
  292.              ReadScreen procedure.
  293.  
  294.              The  routines DO_NOT check for a "collision" between fields.                            ______                                         
  295.              If you write one field on top of another, the last field out 
  296.              will  be the one the user sees.  However,  the value of  the 
  297.              two  fields will be maintained intact,  and if you  retrieve 
  298.              them both you will get the correct values. The visual effect 
  299.              to a user, though, is quite bizarre.
  300.  
  301.           E. Prompt_Fields             _____________
  302.  
  303.              Prompts are strictly for the user's benefit and are  treated 
  304.              very different from data fields.  Once written,  a prompt is 
  305.              forgotten - it remains on the screen, but cannot be accessed 
  306.              thereafter,  other  than to overwrite it with another prompt 
  307.              or a data field.
  308.  
  309.              Prompts  are not numbered and there is no limit to how  many 
  310.              you can write to a screen,  other than the physical capacity 
  311.              of the screen.
  312.  
  313.              The  writing of prompts and data fields may be interspersed.
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.         Pascal Library Member EM3270.INC                 Page 6
  332.  
  333.  
  334.           F. Attributes             __________
  335.  
  336.              An  attribute is a byte associated with a field (either data 
  337.              or  prompt)  which defines certain  characteristics  of  the 
  338.              field. The bits of the byte are used as follows:
  339.  
  340.                             Bit ==>  7  6  5  4  3  2  1  0
  341.                   Attribute Byte =>  X  X  X  X  X  X  X  X
  342.                                      ^  ^  ^  ^  ^        ^
  343.                   0=Bright           |  |  |  |  |________|
  344.                   1=Dim______________|  |  |  |      |
  345.                                         |  |  |      |
  346.                   0=Steady              |  |  |      |
  347.                   1=Blinking____________|  |  |      |
  348.                                            |  |      |
  349.                   0=Visible                |  |      |
  350.                   1=Invisible______________|  |      |
  351.                                               |      |
  352.                   0=Unchanged                 |      |
  353.                   1=Modified__________________|      |
  354.                                                      |
  355.                   0=Use default color                |
  356.                   1-15=Foreground color______________|
  357.  
  358.           G. Field_Appearance             ________________
  359.  
  360.              Original models of the 3270 could display a character in one 
  361.              of  two  brightnesses:   "normal"  (dim)  or   "highlighted" 
  362.              (bright).  Later  models extended this capability to include 
  363.              reverse video and blinking,  as well as color attributes.
  364.  
  365.              The EM3270 procedures implement the attributes in one of two 
  366.              ways,  depending  on  whether they are running on a  machine 
  367.              with a monochrome or color monitor (the EGA is not  support-
  368.              ed). The Steady/Blinking and the Visible/Invisible bits work 
  369.              the same on either type.
  370.  
  371.              If the Steady/Blinking bit is 0, the characters of the field 
  372.              or prompt are displayed normally; if it is 1, they blink off 
  373.              and on in a highly attention-grabbing (and distracting) way. 
  374.              Blinking characters are normally used in rewritten fields to 
  375.              call attention to a data entry error.
  376.  
  377.              If  the Visible/Invisible bit is 0,  the characters  of  the 
  378.              field are displayed normally; if it is 1, they are displayed 
  379.              as spaces (that is,  they are invisible). Moreover, any data 
  380.              keyed into the field will not be displayed. The cursor moves 
  381.              to  the  right as characters are keyed,  and the  characters 
  382.              entered are available to your program, but the person at the 
  383.              keyboard never sees them (unless you display them  elsewhere 
  384.              on the screen in a visible field). In the mainframe environ-
  385.              ment  invisible  fields are commonly used for the  entry  of 
  386.              security  passwords.  Their use in the micro environment  is 
  387.              more limited.
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.         Pascal Library Member EM3270.INC                 Page 7
  398.  
  399.  
  400.              On  the monochrome display,  the Bright/Dim bit  causes  the 
  401.              characters  of the field to be displayed in normal white  on 
  402.              black (Dim) when set to 1, or as inverse video (bright) when 
  403.              set to 0.  In the 3270, the equivalent bit simply causes the 
  404.              equivalent  of  Turbo's LowVideo and  NormVideo  procedures. 
  405.              However, one of the shortcomings of the original 3270 family 
  406.              was  that their was no easy way to show the user the  length 
  407.              of  a  data entry field.  The cursor always moves  into  the 
  408.              leftmost  position  of the field,  but there was nothing  to 
  409.              show  the  user where the right end of the  field  was,  and 
  410.              therefore no sure indication of how many characters he could 
  411.              enter before the cursor jumped to the next field. The intro-
  412.              duction  of inverse video models offered a solution to  this 
  413.              problem  and  programmers quickly adopted  the  standard  of 
  414.              setting  unprotected  (data entry) fields to  inverse.  This 
  415.              standard is implemented in the Bright/Dim bit in EM3270.
  416.  
  417.              On the color display,  the Bright/Dim bit selects one of two 
  418.              background/foreground  color  combinations  (see  section  I 
  419.              below). This has nothing to do with the actual brightness or 
  420.              dimness of the background and characters; it merely provides 
  421.              a convenient way of selecting between two palettes.
  422.  
  423.              The  color  bits of the attribute are used to  override  the 
  424.              foreground  color of the palette selected by the  Bright/Dim 
  425.              bit.  If  these  four bits are 0000,  the palette  color  is 
  426.              displayed. A value of 0001 through 1111 cause the foreground 
  427.              color  to be the equivalent color (dark blue through white). 
  428.              Note  that Turbo provides predefined integer  constants  for 
  429.              each  color  which can be conveniently added or ORed  to  an 
  430.              attribute  byte.  For example,    Attr := LightGreen    will 
  431.              give  an attribute that will cause light green characters on 
  432.              the "bright" background color. The color bits have no effect 
  433.              on a monochrome monitor.
  434.  
  435.              Four  constants  are  defined in EM3270 for  convenience  in 
  436.              working with attributes: Dim, Blinking, Invisible, Modified. 
  437.              These constants facilitate such attribute setting statements 
  438.              as:
  439.  
  440.                        Attr := Dim + Blinking + Magenta;
  441.  
  442.              and attribute testing statements like:
  443.  
  444.                        If (Attr and Modified) <> 0 Then . . .
  445.  
  446.           H. Modified_Data_Tags             __________________
  447.  
  448.              The modified data tag (bit 4) is normally set off (0) when a 
  449.              data field is written.  If the user changes any data in  the 
  450.              field during a ReadScreen procedure,  it will be set on (1). 
  451.              You can,  however turn it on before writing the field and it 
  452.              will  stay  on  no matter what the user does.  If  the  user 
  453.              simply  moves  the cursor through a field  with  the  cursor 
  454.              control keys,  the MDT will not be set.  If the user deletes 
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.         Pascal Library Member EM3270.INC                 Page 8
  464.  
  465.  
  466.              or enters any data in the field,  the MDT will be set,  even                        ___                                                
  467.              if the data is the same as the original contents. The MDT is 
  468.              set  or  not in an invisible field exactly as for a  visible 
  469.              field.
  470.  
  471.           I. Defining_Color_Palettes             _______________________
  472.  
  473.              The background and foreground colors for "bright" and  "dim" 
  474.              fields are controlled by setting four global variables named
  475.  
  476.                             BrightBG, BrightFG
  477.                             DimBG,    DimFG
  478.  
  479.              These are of type Byte.  The background colors may be set to 
  480.              any of the "dark" colors,  0 (Black) through 7  (LightGray). 
  481.              The  foreground colors may be set to any of the 16  standard 
  482.              colors, 0 (Black) through 15 (White).
  483.  
  484.              These  variables may be set or reset at any time and can  be 
  485.              used  to  cause some interesting effects  on  color  screens 
  486.              (they have absolutely no effect on monochrome screens).  For 
  487.              example,  a data entry field can be written with one palette 
  488.              in  effect  and read with another in effect by changing  the 
  489.              palette  variables between the WriteField (or  RewriteField) 
  490.              and  the ReadScreen procedure calls.  As the user keys  data 
  491.              into the field,  the background and foreground colors change 
  492.              as each character is entered.
  493.  
  494.              These  variables  are normally reset immediately  after  the 
  495.              InitScreen procedure call.  InitScreen sets them to white on 
  496.              black  for dim and black on white (inverse video) for black, 
  497.              giving  an  approximation of the apearance of  a  monochrome 
  498.              screen.
  499.  
  500.              Note  that the entire screen background color is set to  the 
  501.              DimBG value,  so that "bright" fields appear as "islands" of 
  502.              the BrightBG color in a sea of DimBG.
  503.  
  504.           J. Field_Positioning             _________________
  505.  
  506.              The  position  of a data or prompt field on  the  screen  is 
  507.              specified  by an "X,Y" pair of coordinate.  X is the  column 
  508.              number on the screen and Y is the line number.
  509.  
  510.              X must be from 1 to 80.  Y must be from 1 to 25.  The use of 
  511.              line 25 is discouraged, except for brief error messages. The 
  512.              procedures  use  the  right end of line 25  to  display  the 
  513.              Insert mode flag,  and other uses for this line may be added 
  514.              to EM3270 in the future.  Besides, the most common models of 
  515.              the 3270 don't have a 25th line.
  516.  
  517.           I. Field_Length             ____________
  518.  
  519.              The  length  of a data or prompt field is specified  at  the 
  520.              time it is written.  The length must be from 1 to 79 charac-
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.         Pascal Library Member EM3270.INC                 Page 9
  530.  
  531.  
  532.              ters.
  533.  
  534.              There  is  no necessary connection between the length  of  a 
  535.              string written to a field and the length of the field.  A 20 
  536.              character  long field can be initialized with a 4  character 
  537.              string  (in which case 16 spaces will be added to the end of 
  538.              the  displayed field),  or with a 100 character  string  (in 
  539.              which  case  the last 80 characters will not be  displayed). 
  540.              However,  when  retrieving  strings from  the  screen,  care 
  541.              should  be taken to ensure that the receiving string  is  at 
  542.              least  as  long as the defined screen field.  Defining a  15 
  543.              character screen field and then trying to read it back  into 
  544.              a  10 character string can cause subtle and insidious  prob-
  545.              lems  that would bring tears to the eyes of the most experi-
  546.              enced Turbo programmers. This flexibility (and its attendant 
  547.              problems)  result from the {$V-} option at the beginning  of 
  548.              your program.
  549.  
  550.              No test is made for "line-wrap".  A 20-character field writ-
  551.              ten at X position 75 will give unpredictable results.
  552.  
  553.           J. AID_Keys             ________
  554.  
  555.              The  AID  keys recognized by EM3270 are the  ENTER  (RETURN) 
  556.              key,   the  ESCAPE  key,   F1..F10,   Alt/F1..Alt/F10,   and 
  557.              Alt/1..Alt/3.  An "enumerated type" is defined at the begin-
  558.              ning of the INCLUDE file:
  559.  
  560.                AID = (Enter,Escape,F1,F2,F3,F4,F5,F6,F7,F8,F9,F10,
  561.                       F11,F12,F13,F14,F15,F16,F17,F18,F19,F20,
  562.                       PA1,PA2,PA3);
  563.  
  564.              Alt/F1..Alt/F2   map  to  F11..F20;   Alt/1..Alt/3  map   to 
  565.              PA1..PA3.
  566.  
  567.              You  must define at least one variable of type AID  to  hold 
  568.              the  value of the AID key pressed to return control to  your 
  569.              program. The value of this variable may be tested for any of 
  570.              its defined values with If or Case statements.
  571.  
  572.              Most  3270  keyboards  have more AID keys  than  this.  3270 
  573.              keyboards have from 9 to 24 PF ("programmed function") keys, 
  574.              plus ATTN,  CLEAR,  and a strange and seldom used one called 
  575.              "Test Req". The PC keyboard's 10 function keys map nicely to 
  576.              the 3270's PF1 through PF20,  using the Alt key to  generate 
  577.              PF11 through PF20,  and the Alt/1 through Alt/3 key combina-
  578.              tions  map to PA1 through PA3.  The RETURN key is mapped  to 
  579.              the 3270 ENTER key by the EM3270 procedures.  The ESCAPE key 
  580.              can be used to simulate the 3270's CLEAR or ATTN key at your 
  581.              option.  If you need more AID keys,  you can modify the fol-
  582.              lowing sections of code in EM3270.INC to add them:
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.         Pascal Library Member EM3270.INC                 Page 10
  596.  
  597.  
  598.                   - The Const section of procedure ReadScreen 
  599.                   - The definition of type AID
  600.                   - Procedure GetChar
  601.                   - The last Case option in procedure ReadScreen
  602.                   - The "Until" test in ReadScreen
  603.  
  604.         III. PROCEDURES
  605.  
  606.           A. InitScreen             __________
  607.  
  608.              USAGE:    InitScreen;    { no parameters }
  609.  
  610.              This procedure has no visible affect.  It merely initializes 
  611.              the heap pointers to Nil,  determines the monitor type,  and 
  612.              sets  the background and foreground colors to their  default 
  613.              values.
  614.  
  615.              THIS  PROCEDURE  MUST BE EXECUTED BEFORE ANY OTHER  EM3270 
  616.              PROCEDURE AND SHOULD BE EXECUTED ONLY ONCE!!!!!
  617.  
  618.           B. NewScreen             _________
  619.  
  620.              USAGE:    NewScreen;     { no parameters }
  621.  
  622.              This procedure clears and resets the screen and deletes  all 
  623.              fields from the heap. It should be used every time a new set 
  624.              of prompts and fields is to be presented.  Using ClrScr will 
  625.              clear  the  screen,  but all data fields from  the  previous 
  626.              screen will still exist and results could be catastrophic.
  627.  
  628.           C. WritePrompt             ___________
  629.  
  630.              USAGE:    WritePrompt (X, Y, Attr, Lngth : Byte;
  631.                                     Strngin           : ScreenLine);
  632.  
  633.                   X = Column number of prompt (1..79)
  634.                   Y = Line number of prompt (1..25)
  635.                   Attr = Atrribute for prompt
  636.                   Lngth = Length of prompt field (1..79)
  637.                   Strngin = Prompt literal (any string)
  638.  
  639.              This  procedure writes one prompt to the screen at the posi-
  640.              tion  indicated  by  X,Y.  All  bits of  the  attribute  are 
  641.              effective except the Visible/Invisible bit and the  Modified 
  642.              Data Tag.
  643.  
  644.          D. WriteField            __________
  645.  
  646.              USAGE:    WriteField (X, Y, Attr, Lngth : Byte;
  647.                                    Strngin           : ScreenLine);
  648.  
  649.                   X = Column number of data field (1..79)
  650.                   Y = Line number of data field (1..25)
  651.                   Attr = Atrribute for data field
  652.                   Lngth = Length of data field (1..79)
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.         Pascal Library Member EM3270.INC                 Page 11
  662.  
  663.  
  664.                   Strng = Data field literal (any string)
  665.  
  666.              This  procedure  defines and writes one data  field  to  the 
  667.              screen  at the position indicated by X,Y with the character-
  668.              istics indicated by Attr.  The field number is determined by 
  669.              the number of executions of WriteField since the last execu-
  670.              tion of NewScreen.
  671.  
  672.           E. ReadScreen             __________
  673.  
  674.              USAGE:    ReadScreen (FieldNo     : Byte;
  675.                                    Var FuncKey : AID);
  676.  
  677.                   FieldNo = Data field number in wich to initially  place 
  678.                             the cursor
  679.                   FuncKey = A  variable  you define in which the AID  key 
  680.                             pressed by the user is returned
  681.  
  682.              This  procedure "unlocks" the keyboard for data  entry.  The 
  683.              procedure  maintains control allowing the user to  enter  or 
  684.              erase data in any data field until an AID key is pressed.
  685.  
  686.              Upon return from ReadScreen,  the position of the cursor  at 
  687.              the  time  the  user pressed the AID key is available  in  a 
  688.              record named "Cursor". Its fields (all of type BYTE) are:
  689.  
  690.                   Cursor.Field   The field number in which the cursor was 
  691.                                  positioned.
  692.                   Cursor.Char    The  character number within the  field. 
  693.                                  May be used to index the string returned 
  694.                                  from the field.
  695.                   Cursor.X       The screen column of the cursor.
  696.                   Cursor.Y       The screen line of the cursor.
  697.  
  698.           F. GetField             ________
  699.  
  700.              USAGE:    GetField (FieldNo   : Byte;
  701.                                  Var Strng : ScreenLine;
  702.                                  Var Attr  : Byte);
  703.  
  704.                   FieldNo = Data field number to be retrieved
  705.                   Strng = Returned  string  containing current  value  of 
  706.                           field.  Must be at least as long as the defined 
  707.                           field.            
  708.                   Attr = Returned current attribute of data field
  709.  
  710.              This procedure returns the current value of a data field. It 
  711.              is normally used after a ReadScreen procedure, once for each 
  712.              field to be examined.
  713.  
  714.           G. RewriteField             ____________
  715.  
  716.              USAGE:    RewriteField (FieldNo : Byte;
  717.                                      Strngin : ScreenLine;
  718.                                      Attr    : Byte);
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.         Pascal Library Member EM3270.INC                 Page 12
  728.  
  729.  
  730.  
  731.                   FieldNo = Data field number to be rewritten
  732.                   Strng = String to be written
  733.                   Attr = New attribute for field
  734.  
  735.              This procedure replaces the value of a data field already on 
  736.              the screen. Some occasions on which it is normally used are:
  737.  
  738.                1. Displaying  records  from  a file which  the  user  may 
  739.                   change.
  740.  
  741.                2. Displaying default values which may be overkeyed.
  742.  
  743.                3. Rewriting  a field that has failed an edit test with  a 
  744.                   blinking or alternate color attribute.
  745.  
  746.                2. The data field has been "prettied up" by editing and is 
  747.                   being displayed in its modified form for the benefit of 
  748.                   the user.
  749.  
  750.           H. SetVid             ______
  751.              NormVid             _______
  752.              LowVid             ______
  753.  
  754.              USAGE     SetVid (At : Byte);
  755.                        NormVid (At : Byte);
  756.                        LowVid (At : Byte);
  757.  
  758.                   At = Attribute byte
  759.  
  760.              These procedures may be used to set the video mode based  on 
  761.              an attribute byte at any time. SetVid sets the mode based on 
  762.              the  entire attribute except for the Visible/Invisible  bit. 
  763.              NormVid  and  LowVid bypass the Bright/Dim bit and  set  the 
  764.              video mode directly to "bright" or "dim" respectively,  with 
  765.              blink and color as specified by the attribute.
  766.  
  767.              Calls  to  these procedures are normally made  before  using 
  768.              Turbo's  Write or WriteLn procedures to add something to  an 
  769.              existing screen (an error message on line 25, for instance). 
  770.              You  could use TextBackground and TextColor just as  easily,                   _____                                                   
  771.              but  the  use  of these procedures will  keep  your  program 
  772.              "attribute oriented".
  773.  
  774.         IV. OPERATION
  775.  
  776.           A. Cursor_Control             ______________
  777.  
  778.              During  the  ReadScreen  procedure the cursor can  be  moved 
  779.              anywhere in any data field without affecting the contents of 
  780.              the fields by the use of several cursor control  keys.
  781.  
  782.              Cursor  movements  and  the keys which control them  are  as 
  783.              follows:
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.         Pascal Library Member EM3270.INC                 Page 13
  794.  
  795.  
  796.              CURSOR RIGHT:  Right Arrow. Moves the cursor one position to 
  797.                        the right without affecting data. if the cursor is 
  798.                        in the last position of a field,  it jumps to  the 
  799.                        beginning of the next field.
  800.  
  801.              CURSOR LEFT:  Left  Arrow.  Moves the cursor one position to 
  802.                        the left without affecting data.  If the cursor is 
  803.                        in the first position of a field,  it jumps to the 
  804.                        beginning of the preceding field.
  805.  
  806.              TAB RIGHT:  TAB  key.  Moves the cursor to the beginning  of 
  807.                        the next data field without affecting data.
  808.  
  809.              TAB LEFT:  Shifted TAB or Backspace key. Moves the cursor to 
  810.                        the  beginning of the preceding data field without 
  811.                        affecting data.  The Backspace key is used because 
  812.                        it  is in the approximate position of the  Backtab 
  813.                        key  on most 3270 keyboards.  Shifted TAB is  also 
  814.                        used, because of PC conventions.
  815.  
  816.              NEW LINE:  PgDn  key.  Moves the cursor to the beginning  of 
  817.                        the  first data field on the next line down  which 
  818.                        contains  a data field.  If the cursor line is the 
  819.                        last  such  line on the screen  the  cursor  wraps 
  820.                        around  to the first line containing a data field. 
  821.                        The choice of PgDn is arbitrary, and can easily be 
  822.                        changed to Down Arrow or some other key.  Unfortu-
  823.                        nately, on most 3270 keyboards the New Line key is 
  824.                        in  about  the same position as  the  PC's  Return 
  825.                        (Enter) key,  and moreover is marked the same (ar-
  826.                        row  down and left).  If the Return key were  used 
  827.                        for New Line, there would be no appropriate key to 
  828.                        use  for  Enter.  (The 3270's Enter key  is  about 
  829.                        where  the  PC's Caps Lock key is,  except on  the 
  830.                        3270 "data entry" keyboards,  where it is  located 
  831.                        roughly  where the PC's left bracket key  is.  IBM 
  832.                        was never much good at ergonomics or consistency.) 
  833.                        Also,  you'd  think  that logically the  PgUp  key 
  834.                        would  jump  the cursor UP one line;  there is  no 
  835.                        such key on the 3270.
  836.  
  837.              HOME:      The Home key returns the cursor to the first data 
  838.                        field on the screen.
  839.  
  840.           B. Editing_Keys             ____________
  841.  
  842.              INSERT MODE:  Ins key.  In insert mode,  characters typed by 
  843.                        the  user  are inserted at  the  cursor  position, 
  844.                        pushing characters right until a non-blank charac-
  845.                        ter  is the last in the field.  This is a  toggle. 
  846.                        Pressing it again turns off insert mode. (The 3270 
  847.                        keyboard  has  a RESET key which turns off  insert 
  848.                        mode.)
  849.  
  850.              DELETE:   Del  key.  The character at the cursor is  deleted 
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.         Pascal Library Member EM3270.INC                 Page 14
  860.  
  861.  
  862.                        and  all characters in the field to the right  are 
  863.                        shifted left one position. A space is shifted into 
  864.                        the rightmost position of the field.
  865.  
  866.              ERASE EOF: End  key.  All characters in the data field  from 
  867.                        the  cursor position to the end of the  field  are 
  868.                        set to spaces (erased).  This is another arbitrary 
  869.                        key choice, since there is no analogous key on the 
  870.                        PC.
  871.  
  872.           C. Data_Entry             __________
  873.  
  874.              Any printable ASCII character entered ($20..$7E or ' '..'~') 
  875.              will  replace the character in the cursor position and  turn 
  876.              on the modified data tag of the field.
  877.  
  878.           D. Data_Transmission             _________________
  879.  
  880.              When all data entry has been completed,  control is returned 
  881.              to the application program by pressing any of the AID keys.
  882.  
  883.         V. PROBLEMS
  884.  
  885.           A. One of the most common problems in using EM3270 is FORGET-
  886.              TING TO CALL INITSCREEN before the first call to one of  the 
  887.              other  procedures.  The symptoms of this are almost always a 
  888.              totally "locked up" system.
  889.  
  890.           B. CALLING  WRITEFIELD  MORE THAN MAXFIELDS TIMES  will  almost 
  891.              always send your program into never never land.
  892.  
  893.           C. FORGETTING  TO CALL NEWSCREEN before writing prompts or cal-
  894.              ling WriteField will not lock up the system, but will result 
  895.              in "garbage" screens and unpredictable cursor positioning.
  896.  
  897.           D. OVERLAPPING  FIELDS  AND/OR  PROMPTS are  simply  errors  in 
  898.              specifying correct X/Y values in WritePrompt and WriteField.
  899.  
  900.           E. SPECIFYING  A FIELD NUMBER HIGHER THAN THE HIGHEST  ONE  DE-
  901.              FINED in arguments to ReadScreen,  RewriteField and GetField 
  902.              causes  unpredictable  results - frequently a  total  system 
  903.              lockup.
  904.  
  905.           F. THE  RETURN KEY can cause problems to people who are used to 
  906.              the  Teletype  (and PC) standard of hitting  it  after  each 
  907.              field.  It  can also cause problems for some 3270  operators 
  908.              since  on the PC keyboard it is in the sames position as the 
  909.              NEW LINE key on most 3270 keyboards.  One way to get  around 
  910.              this is to modify the EM3270 procedures so that the RETURN 
  911.              key is not one of the AID keys,  but performs the same func-
  912.              tion  as TAB or PgDn.  Another way is to eliminate the ENTER 
  913.              function  through programming:  every time you  return  from 
  914.              ReadScreen  with  an AID value of ENTER,  simply go back  to 
  915.              ReadScreen  again with the cursor placed in the  next  field 
  916.              (determined  by  adding 1 to Cursor.Field and  allowing  for 
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.         Pascal Library Member EM3270.INC                 Page 15
  926.  
  927.  
  928.              falling  out of the last screen field).  In either of  these 
  929.              solutions, you sacrifice the ENTER AID function and must use 
  930.              only the function keys or ESCAPE to get your data.
  931.  
  932.  
  933.  
  934.  
  935.  
  936.  
  937.  
  938.  
  939.  
  940.  
  941.  
  942.  
  943.  
  944.  
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.